<!--
 * @Description: 检测数据查询
 * @Autor: xiej
 * @Date: 2020-08-27 11:46:17
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-02-25 18:02:55
-->h
<template>
  <div class="app-content h-flex">
    <div class="datas-cent h-flex-elastic">
      <keep-alive>
        <component
          :is="currentAnalysis"
          :line-code="lineCode"
          style="height: 97%;"
          @find-detect-data="findDetectData" />
      </keep-alive>
    </div>
  </div>
</template>

<script>
import A4C from './components/A4cCopy'
import {
  find4cDetectData } from '@/api/cms/detect-data'
export default {
  name: 'DetectData',
  components: {
    A4C
  },
  props: {
    tophie: {
      type: String,
      default: 'true'
    },
    hideHeader: {
      type: Boolean,
      default: false
    },
    param: {
      type: Object
    }
  },
  data() {
    return {
      currentAnalysis: 'A4C',
      tableDataDefect: {},
      lineCode: ''
    }
  },
  watch: {
    param(val) {
      if (val) {
        const queryParams = {}
        queryParams.lineCode = val.lineCode
        this.lineCode = val.lineCode
        this.currentAnalysis = val.ctype
        this.findDetectData(queryParams)
      }
    }
  },
  mounted() {
    // const queryParams = {}
    // this.find4cDetectData(queryParams)
  },
  destroyed() {
    window.removeEventListener('keyup', this.handleKeyup)
  },
  methods: {
    changeCurrentAnalysis(val) {
      this.currentAnalysis = val
    },
    findDetectData(queryParams) {
      const val = this.currentAnalysis
      if (val === 'A4C') {
        this.find4cDetectData(queryParams)
      }
    },
    find4cDetectData(queryParams) {
      this.tableDataDefect = {}
      find4cDetectData(queryParams).then(response => {
        // console.log('4C检测数据查询', response)
        if (response.data) {
          this.tableDataDefect = response.data
        }
      })
    }
  }
}
</script>

